Dashboard.addWidget({ getId : function(){ return 'panel-overview-widget'; }, getName : function(){ return 'Panel Overview'; }, getDescription : function(){ return { en : 'Widget that display a multi-panel view of the KPI model content', de : 'Widget that display a multi-panel view of the KPI model content' }; }, getIconClass : function(){ return 'glyphicon glyphicon-filter'; }, createContent : function(configuration, currentWidgetInstanceId){ var treeStructure = ModelManager.buildModelLinearStructure(); var dataNode = $('
'); var filterNode = $('
'); var _initializeFilterNode = function(){ filterNode.empty(); filterNode.append( $('\ \ ') ).change(function(e){ var showSuccessGoal = filterNode.find('#successChk').is(':checked'); var showFailureGoal = filterNode.find('#failureChk').is(':checked'); var showUnknownGoal = filterNode.find('#unknownChk').is(':checked'); var minKpiVal = filterNode.find('#greaterTxt').val(); var sameKpiVal = filterNode.find('#equalTxt').val(); var maxKpiVal = filterNode.find('#lowerTxt').val(); dataNode.find('div[isGoal="true"]').each(function(){ $(this).hide(); if(showSuccessGoal && $(this).attr('lastValue') > 0) $(this).show(); if(showFailureGoal && $(this).attr('lastValue') < 0) $(this).show(); if(showUnknownGoal && $(this).attr('lastValue') == 0) $(this).show(); }); dataNode.find('div[isGoal="false"]').each(function(){ $(this).show(); if(minKpiVal != '' && !($(this).attr('lastValue') > minKpiVal)) $(this).hide(); if(sameKpiVal != '' && !($(this).attr('lastValue') == sameKpiVal)) $(this).hide(); if(maxKpiVal != '' && !($(this).attr('lastValue') < maxKpiVal)) $(this).hide(); }); }); Dashboard.events.onFilterByValuesChange(function(e){ var showSuccessGoal = e.showSuccessGoal; var showFailureGoal = e.showFailureGoal; var showUnknownGoal = e.showUnknownGoal; var minKpiVal = e.minKpiVal; var sameKpiVal = e.sameKpiVal; var maxKpiVal = e.maxKpiVal; filterNode.find('#successChk').prop('checked', showSuccessGoal); filterNode.find('#failureChk').prop('checked', showFailureGoal); filterNode.find('#unknownChk').prop('checked', showUnknownGoal); filterNode.find('#greaterTxt').val(minKpiVal); filterNode.find('#equalTxt').val(sameKpiVal); filterNode.find('#lowerTxt').val(maxKpiVal); dataNode.find('div[isGoal="true"]').each(function(){ $(this).hide(); if(showSuccessGoal && $(this).attr('lastValue') > 0) $(this).show(); if(showFailureGoal && $(this).attr('lastValue') < 0) $(this).show(); if(showUnknownGoal && $(this).attr('lastValue') == 0) $(this).show(); }); dataNode.find('div[isGoal="false"]').each(function(){ $(this).show(); if(minKpiVal != '' && !($(this).attr('lastValue') > minKpiVal)) $(this).hide(); if(sameKpiVal != '' && !($(this).attr('lastValue') == sameKpiVal)) $(this).hide(); if(maxKpiVal != '' && !($(this).attr('lastValue') < maxKpiVal)) $(this).hide(); }); }); }; _initializeFilterNode(); var _onCleanSelection = function(){ dataNode.empty(); }; var _createWidgetPanel = function(modelId, isGoal, objectId){ if(modelId==null || isGoal==null || objectId==null) return null; var objInfo = isGoal?ModelManager.getGoalInfo(modelId, objectId):ModelManager.getKpiInfo(modelId, objectId); var _createCircleCode = function(color){ return''; } var _formatGoalStatusAsTrafficLightCode = function(status){ if(status == null) return _createCircleCode('lightgrey')+' '+_createCircleCode('lightgrey')+' '+_createCircleCode('lightgrey'); return _createCircleCode(status>0?'green ':'lightgrey')+' '+_createCircleCode(status==0?'grey ':'lightgrey')+' '+_createCircleCode(status<0?'red ':'lightgrey'); } var _formatKpiValue = function(value, measureUnit){ if(value == null) value = '--'; return '
' + value + ' ' + measureUnit + '
'; }; var measure = null; var lastValue = null; var errorMsg = null; try{ measure = isGoal ? Dashboard.evaluateGoal(currentWidgetInstanceId, modelId, objInfo.id) : Dashboard.evaluateKpi(currentWidgetInstanceId, modelId, objInfo.id); lastValue = isGoal ? measure.status : ((measure.data.length>0 && measure.columns.length>0)?measure.data[0][measure.columns[0]]:null); }catch(e){ errorMsg = e; } var valueToDisplay = isGoal ? _formatGoalStatusAsTrafficLightCode(lastValue) : _formatKpiValue(lastValue, (measure!=null && measure.columns.length>0)?objInfo.getFieldInfos(measure.columns[0]).measureUnit:''); var panelDiv = $('
').append( $('
').append( $('

' + objInfo.name + '

') ) ).append( $('
').append( $('
' + valueToDisplay + '
') ).popover({ placement : 'auto right', container : 'body', html : true, title : objInfo.name + ' details', content : function(){ var html = '

'+objInfo.description+'

'; if(errorMsg != null){ html += '

Error Occurred: '+errorMsg+'

'; return html; } if(measure==null) throw 'Unexpected Exception!'; if(isGoal){ html += ''; html += ''; html += ''; if(objInfo.type!=null) html += ''; for(var moreInfoKey in measure.moreInfo) html += ''; html += '
DetailsValues
status'+(measure.status==0?'UNKNOWN':(measure.status>0?'SUCCESS':'FAILURE'))+'
type'+objInfo.type+'
'+moreInfoKey+''+measure.moreInfo[moreInfoKey]+'
'; } else { var targetRangeStatusHtml = ''; if(measure.targetRangeAlgorithmResult!=null){ var targetRangeStatus = measure.targetRangeAlgorithmResult.status; targetRangeStatusHtml = _createCircleCode(targetRangeStatus==null?'lightgrey':(targetRangeStatus>0?'green':(targetRangeStatus<0?'red':'grey'))); } var alertRangeStatusHtml = ''; for(var i=0;i'; html += ''; html += ''; measure.columns.forEach(function(item){ html += ''; }); html += ''; measure.data.forEach(function(dataItem, index){ if(index > 10) return; html += ''; measure.columns.forEach(function(columnName){ html += ''; }); html += ''; }); if(measure.data.length > 10){ html += ''; measure.columns.forEach(function(item, i){ html += ''; }); html += ''; } html += '
'+item+'
' + (dataItem[columnName]!=null?dataItem[columnName] + ' ' + objInfo.getFieldInfos(columnName).measureUnit :'') + '
'+(i==0?'...':'')+'
'; html += '

More informations:

'; html += ''; if(objInfo.type!=null) html += ''; for(var moreInfoKey in measure.moreInfo) html += ''; if(Object.keys(measure.moreInfo).length==0 && objInfo.type==null) html += ''; html += '
type'+objInfo.type+'
'+moreInfoKey+''+measure.moreInfo[moreInfoKey]+'
No additional infos available
'; } return html; }(), trigger : 'hover' }) ); return panelDiv; }; var _onSelection = function(modelId, isGoal, objectId){ /* //TODO: mantenere entrambi gli algoritmi e usare quello commentato solo se il tipo di albero usato รจ lo stesso var _getSelectedTreeNodeRec = function(currentNode){ if(currentNode.levelId == levelId) return currentNode; else { var nextNode = null; if(currentNode.nodes!=null) for(var i=0;i').treeview({ data : [treeStructure], color : "#428bca", expandIcon : 'glyphicon glyphicon-chevron-right', collapseIcon : 'glyphicon glyphicon-chevron-down', onNodeSelected : function(event, data) { _onSelection(data.model_id, data.isAGoal, data.object_id); }, onNodeUnselected : function(event, data) { _onCleanSelection(); }, }).treeview('expandAll', { silent: true }); /* var _createModelTreeNoDependencies = function(){ var treeJson = this._generateJsonTreeFromModel(); var _createModelRec = function(rootArrayJson){ var ulNode = $('
    '); //list-group collapse in //navbar-collapse rootArrayJson.forEach(function(item){ ulNode.append( function(item){ var ulNodeToAppend = item.nodes==null?null:_createModelRec(item.nodes); var dataTarget = ulNodeToAppend==null?'':' data-parent="#' + ulNode.attr('id') + '" data-toggle="collapse" data-target="#' + ulNodeToAppend.attr('id') + '"'; return $('
  • ') //class="list-group-item" .append( $('') //href="#" .click(function(e){ _onSelection(item.model_id, item.isAGoal, item.object_id); }) ) .append(ulNodeToAppend) ; }.call(this, item) ); }); return ulNode; }; return $('
    ').append(_createModelRec(treeJson)); }.bind(this); var treeNode = _createModelTreeNoDependencies(); */ var ret = $('
    ').append( $('
    ') .append(treeNode) .append(filterNode) ).append( $('
    ').append(dataNode) ); _onSelection(null, null, null); return ret; }, getConfiguration : function(){ return {}; }, createConfiguration : function(presetConfig){ return { nodeElement : null, okHandler : function(){return {};} }; }, getPreferredSize : function(){ return {w:10, h:6}; } });